import "crvpuppet"

class condor_base {
  package { "condor":
    ensure => installed,
  }
}


define at3_condorhead($nfsserverclientmount, $filesystemdomain,$condorpassword,$condor_allow_negotiator_extra) {

  #$NFSServerClientMount=get_provider_attr($webaddr,$roleid,"NFSServerClientMount")
  #  $filesystemdomain=get_role_attr($webaddr,$roleid,"FILESYSTEM_DOMAIN")
  #  $condorpassword=get_role_attr($webaddr,$roleid,"condorpassword")
  #  $condor_allow_negotiator_extra=""
  
    file { "$nfsserverclientmount/condor":
      owner => "root",
      group => "root",
      ensure => directory,
      mode => 755,
    }
    
    file { "$nfsserverclientmount/condor/condor_config":
      owner => "root",
      group => "root",
      mode => 644,
      content => template("at3_condorhead/condor_config.tpl"),
      require => File["$nfsserverclientmount/condor"],
    }

    file { "/etc/condor/condor_config":
      owner => "root",
      group => "root",
      ensure  => symlink,
      replace => true,
      require => File["$nfsserverclientmount/condor"],      
      target    => "$nfsserverclientmount/condor/condor_config",
    }

    file { "/etc/condor/condor_config.local":
      owner => "root",
      group => "root",
      mode => 644,
      content => template("at3_condorhead/condor_config.local.tpl"),
    }

    exec { create_condorpassword:
      command => "condor_store_cred -c add -p $condorpassword",
      require => File["/etc/condor/condor_config","/etc/condor/condor_config.local"],
      creates => "/var/condor_credentiald",
    }
    
    include condor_base
    
    service { [ "condor"]:
      ensure => running,
      enable => true,
      hasstatus => true,
      hasrestart => true,
      require => [Package["condor"],Exec["create_condorpassword"]],
    }

}

#    set_role_attr($webaddr,$roleid,"CondorHeadAddr","$fqdn")    

